﻿using BCDto.TMS.VehicleCategoryReference;
using System;
using System.Collections.Generic;
using BCCommon.TMS.Driver;
using BCCommon.Extensions;

namespace BCDto.TMS.VehicleType
{
    /// <summary>
    /// 车辆类型输出模型
    /// </summary>
    public class VehicleTypeDto
    {
        /// <summary>
        /// 车型Id
        /// </summary>
        public int VehicleTypeId { get; set; }

        /// <summary>
        /// 车型图片路径
        /// </summary>
        public string VehiclePicPath { get; set; }

        /// <summary>
        /// 车型名称
        /// </summary>
        public string VehicleTypeName { get; set; }

        /// <summary>
        /// 车辆所属类型（对应字典引用检索键）
        /// </summary>
        public string VehicleTypeEnum { get; set; }

        /// <summary>
        /// 车辆所属类型中文
        /// </summary>
        public string VehicleTypeValue { get; set; }

        /// <summary>
        /// 适用业务类型
        /// </summary>
        public DriverRoleType AppliedTo { get; set; }

        /// <summary>
        /// 适用业务类型
        /// </summary>
        public string AppliedToStr { get { return this.AppliedTo.GetDescriptionString(); } }

        /// <summary>
        /// 车辆长度
        /// </summary>
        public decimal VehicleLength { get; set; }

        /// <summary>
        /// 车辆宽度
        /// </summary>
        public decimal VehicleWidth { get; set; }

        /// <summary>
        /// 车辆高度
        /// </summary>
        public decimal VehicleHeight { get; set; }

        /// <summary>
        /// 车辆长度系数
        /// </summary>
        public decimal VehicleLengthRatio { get; set; }

        /// <summary>
        /// 车辆宽度系数
        /// </summary>
        public decimal VehicleWidthRatio { get; set; }

        /// <summary>
        /// 车辆高度系数
        /// </summary>
        public decimal VehicleHeightRatio { get; set; }

        /// <summary>
        /// 车辆轴距
        /// </summary>
        public decimal? VehicleWheelbase { get; set; }

        /// <summary>
        /// 最大载重
        /// </summary>
        public int MaxWeight { get; set; }

        /// <summary>
        /// 最大载货立方
        /// </summary>
        public decimal MaxStere { get; set; }

        /// <summary>
        /// 已启用
        /// </summary>
        public bool Enabled { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// 编辑人
        /// </summary>
        public string Editer { get; set; }

        /// <summary>
        /// 油耗
        /// </summary>
        public decimal? OilConsumption { get; set; }

        /// <summary>
        /// 油耗价格
        /// </summary>
        public decimal? OilConsumptionPrice { get; set; }

        /// <summary>
        /// 每日利润
        /// </summary>
        public decimal? EverdayProfit { get; set; }

        /// <summary>
        /// 车辆所属分类
        /// </summary>
        public List<VehicleCategoryReferenceDto> VehicleSubCategoryList { get; set; }

        /// <summary>
        /// 车辆所属类型ID(拼接)
        /// </summary>
        public string VehicleCategoryReferenceIdStr { get; set; }


        /// <summary>
        /// 获取长宽高最大值
        /// </summary>
        /// <returns></returns>
        public decimal GetLength()
        {
            decimal Length = VehicleLength - VehicleLengthRatio;
            decimal Width = VehicleWidth - VehicleWidthRatio;
            decimal Height = VehicleHeight - VehicleHeightRatio;

            decimal max = Length;
            if (Width > max)
                max = Width;
            if (Height > max)
                max = Length;
            return max;
        }

        /// <summary>
        /// 获取长宽高中间值
        /// </summary>
        /// <returns></returns>
        public decimal GetWidth()
        {
            decimal Length = VehicleLength - VehicleLengthRatio;
            decimal Width = VehicleWidth - VehicleWidthRatio;
            decimal Height = VehicleHeight - VehicleHeightRatio;

            decimal maxAB = Math.Max(Length, Width);
            decimal minAB = Math.Min(Length, Width);

            return maxAB > Height ? Math.Max(minAB, Height) : maxAB;
        }

        /// <summary>
        /// 获取长宽高最小值
        /// </summary>
        /// <returns></returns>
        public decimal GetHight()
        {
            decimal Length = VehicleLength - VehicleLengthRatio;
            decimal Width = VehicleWidth - VehicleWidthRatio;
            decimal Height = VehicleHeight - VehicleHeightRatio;

            decimal min = Length;
            if (Width < min)
                min = Width;
            if (Height < min)
                min = Height;
            return min;
        }
    }
}